<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>查看试卷</title>
		<link rel="stylesheet" type="text/css" href="/ExamOnline/easyui/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="/ExamOnline/easyui/themes/icon.css">
		<script type="text/javascript" src="/ExamOnline/easyui/jquery.min.js"></script>
		<script type="text/javascript" src="/ExamOnline/easyui/jquery.easyui.min.js"></script>
	</head>

	<body>
		<table id="dg" width="100%"  style="min-height:500px;"></table>
	</body>
	<script>
		$("#dg").datagrid({
			url: '/ExamOnline/paper/list',
			rownumbers: 'true',
			autoRowHeight: 'false',
			method: 'get',
			fitColumns: 'true',
			singleSelect : 'true',
			pagination : 'true',//pagination将发送两个参数到服务器：page：页码，起始值 1。rows：每页显示行。
			pageSize : 5,//每页显示的记录条数，默认为10 ,不可单独设置该属性，要与pageList一起设置。
			pageList : [ 5, 10, 15 ],//可以设置每页记录条数的列表 
			columns:[[
			{field:'papername',title:'试卷标题',width:100},
			{field:'examtime',title:'考试时间',align:'center'},
			{field:'totalscore',title:'总分',align:'center'},
			{field:'passscore',title:'及格分数',align:'center'},
			{field:'createtime',title:'创建时间',align:'center'},
			{field:'test',title:'操作',align:'center',formatter:formatOper}
			]]
		});
		function formatOper(val, row, index) {
			return '<a href="#" onclick="showValue(' + index + ')">查看</a>&nbsp;<a href="#" onclick="editpanel(' + row.id + ')">修改</a>&nbsp;<a href="#" onclick="delValue(' + row.id + ')">删除</a>';
		}
		
		function showValue(index){
			$.messager.alert('提示消息', "功能尚未实现！");
		}
		function delValue(id){
			$.messager.confirm('消息提示', '您确定要删除吗？', function(r) {
				if (r) {
					$.post("/ExamOnline/paper/delete", "id=" + id, function(r) {
						$.messager.alert('消息提示', r);
						$("#dg").datagrid('reload');
					});
				}
			});
		}
		function editpanel(id){
			var jq = top.jQuery;
			var title = "修改试卷";
			var url ="paper/edit.html";
			if (jq("#tabs").tabs('exists', title)){
				jq("#tabs").tabs('close', title);
			}
			var content = '<iframe scrolling="auto" frameborder="0"  src="'+url+'" style="width:100%;height:100%;"></iframe>';
			jq("#tabs").tabs('add',{
				id:id,
				title:title,
				content:content,
				closable:true
			});
			}
	</script>

</html>